home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / LT_Rebuild.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-18  |  4.9 KB  |  223 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. BOOL LIBENT
  10. LT_RebuildTagList(REG(a0) LayoutHandle *handle,REG(d0) BOOL clear,REG(a1) struct TagItem *TagParams)
  11. {
  12.     struct TagItem    *item,
  13.             *list;
  14.  
  15.     struct IBox    *bounds = NULL;
  16.  
  17.     list = TagParams;
  18.  
  19.     while(item = NextTagItem(&list))
  20.     {
  21.         switch(item -> ti_Tag)
  22.         {
  23.             case LAWN_Bounds:
  24.  
  25.                 bounds = (struct IBox *)item -> ti_Data;
  26.                 break;
  27.         }
  28.     }
  29.  
  30.     if(handle)
  31.     {
  32.         struct Gadget    *gadget;
  33.         ObjectNode    *node;
  34.         LONG         left,top;
  35.         struct IBox     newBounds;
  36.         LONG         i;
  37.  
  38.         if(!handle -> SizeVerified)
  39.             RemoveGList(handle -> Window,handle -> List,(UWORD)-1);
  40.  
  41.         gadget = handle -> List;
  42.  
  43.         while(gadget)
  44.         {
  45.             if(GETOBJECT(gadget,node))
  46.             {
  47.                 LTP_PutStorage(node);
  48.  
  49.                 switch(node -> Type)
  50.                 {
  51.                     case PICKER_KIND:
  52.  
  53.                         if(node -> Special . Picker . Image)
  54.                         {
  55.                             DisposeObject(node -> Special . Picker . Image);
  56.  
  57.                             node -> Special . Picker . Image = NULL;
  58.                         }
  59.  
  60.                         break;
  61.  
  62.                     case TAPEDECK_KIND:
  63.  
  64.                         if(node -> Special . TapeDeck . ButtonImage)
  65.                         {
  66.                             DisposeObject(node -> Special . TapeDeck . ButtonImage);
  67.  
  68.                             node -> Special . TapeDeck . ButtonImage = NULL;
  69.                         }
  70.  
  71.                         break;
  72.  
  73.                     case INCREMENTER_KIND:
  74.  
  75.                         if(node -> Special . Incrementer . Image)
  76.                         {
  77.                             DisposeObject(node -> Special . Incrementer . Image);
  78.  
  79.                             node -> Special . Incrementer . Image = NULL;
  80.                         }
  81.  
  82.                         break;
  83.  
  84.                     case STRING_KIND:
  85.  
  86.                         if(!node -> Special . String . Backup)
  87.                             node -> Special . String . Backup = (STRPTR)LTP_Alloc(handle,node -> Special . String . MaxChars + 1);
  88.  
  89.                         if(node -> Special . String . Backup)
  90.                         {
  91.                             strcpy(node -> Special . String . Backup,((struct StringInfo *)gadget -> SpecialInfo) -> Buffer);
  92.  
  93.                             node -> Special . String . String = node -> Special . String . Backup;
  94.                         }
  95.  
  96.                         node -> Special . String . Picker = NULL;
  97.  
  98.                         break;
  99.  
  100.                     case TEXT_KIND:
  101.  
  102.                         node -> Special . Text . Picker = NULL;
  103.  
  104.                         break;
  105.  
  106.                     case INTEGER_KIND:
  107.  
  108.                         node -> Special . Integer . LeftIncrementer = NULL;
  109.                         node -> Special . Integer . RightIncrementer = NULL;
  110.  
  111.                         break;
  112. #ifdef DO_LEVEL_KIND
  113.                     case LEVEL_KIND:
  114.  
  115.                         if(node -> Special . Level . LevelImage)
  116.                         {
  117.                             DisposeObject(node -> Special . Level . LevelImage);
  118.  
  119.                             node -> Special . Level . LevelImage = NULL;
  120.                         }
  121.  
  122.                         break;
  123. #endif    /* DO_LEVEL_KIND */
  124.                 }
  125.  
  126.                 node -> Host = NULL;
  127.             }
  128.  
  129.             gadget = gadget -> NextGadget;
  130.         }
  131.  
  132.         FreeGadgets(handle -> List);
  133.  
  134.         handle -> List = NULL;
  135.  
  136.         LTP_Free(handle,handle -> GadgetArray,sizeof(struct Gadget *) * handle -> Count);
  137.  
  138.         handle -> GadgetArray = NULL;
  139.  
  140.         handle -> Count = handle -> Index = 0;
  141.  
  142.         LTP_ResetGroups(handle -> TopGroup);
  143.  
  144.         if(!bounds)
  145.         {
  146.             LTP_GetDisplayClip(handle -> Screen,&newBounds . Left,&newBounds . Top,&newBounds . Width,&newBounds . Height);
  147.  
  148.             bounds = &newBounds;
  149.         }
  150.  
  151.         left    = handle -> Window -> BorderLeft + handle -> InterWidth;
  152.         top    = handle -> Window -> BorderTop + handle -> InterHeight;
  153.  
  154. //        LTP_CreateGadgets(handle,bounds,left,top,left + handle -> InterWidth + handle -> Window -> BorderRight,top + handle -> InterHeight + handle -> Window -> BorderBottom);
  155.         LTP_CreateGadgets(handle,bounds,left,top,left + handle -> InterWidth + handle -> Screen -> WBorRight,top + handle -> InterHeight + handle -> Screen -> WBorBottom);
  156.  
  157.         if(handle -> Failed)
  158.         {
  159.             handle -> SizeVerified = FALSE;
  160.  
  161.             EraseRect(&handle -> RPort,handle -> Window -> BorderLeft,handle -> Window -> BorderTop,handle -> Window -> Width - (handle -> Window -> BorderRight + 1),handle -> Window -> Height - (handle -> Window -> BorderBottom + 1));
  162.  
  163.             RefreshWindowFrame(handle -> Window);
  164.  
  165.             return(FALSE);
  166.         }
  167.  
  168.         if(clear)
  169.         {
  170.             EraseRect(&handle -> RPort,handle -> Window -> BorderLeft,handle -> Window -> BorderTop,handle -> Window -> Width - (handle -> Window -> BorderRight + 1),handle -> Window -> Height - (handle -> Window -> BorderBottom + 1));
  171.  
  172.             if(!handle -> SizeVerified)
  173.                 RefreshWindowFrame(handle -> Window);
  174.         }
  175.  
  176.         handle -> SizeVerified = FALSE;
  177.  
  178.         LTP_AddGadgets(handle);
  179.  
  180.         handle -> Previous = NULL;
  181.  
  182.         for(i = 0 ; i < handle -> Count ; i++)
  183.         {
  184.             if(handle -> GadgetArray[i])
  185.             {
  186.                 if(GETOBJECT(handle -> GadgetArray[i],node))
  187.                 {
  188.                     if(LIKE_STRING_KIND(node) || (node -> Type == INTEGER_KIND))
  189.                     {
  190.                         if(!handle -> Previous)
  191.                             handle -> Previous = handle -> GadgetArray[i];
  192.                     }
  193.                 }
  194.             }
  195.         }
  196.  
  197.         return(TRUE);
  198.     }
  199.     else
  200.         return(FALSE);
  201. }
  202.  
  203. BOOL __stdargs
  204. LT_RebuildTags(LayoutHandle *Handle,BOOL Clear,...)
  205. {
  206.     va_list VarArgs;
  207.     BOOL    Result;
  208.  
  209.     va_start(VarArgs,Clear);
  210.     Result = LT_RebuildTagList(Handle,Clear,(struct TagItem *)VarArgs);
  211.     va_end(VarArgs);
  212.  
  213.     return(Result);
  214. }
  215.  
  216. BOOL LIBENT
  217. LT_Rebuild(REG(a0) LayoutHandle *handle,REG(a1) struct IBox *bounds,REG(a2) LONG extraWidth,REG(d0) LONG extraHeight,REG(d1) BOOL clear)
  218. {
  219.     return(LT_RebuildTags(handle,clear,
  220.         LAWN_Bounds,bounds,
  221.     TAG_DONE));
  222. }
  223.